home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Cafe 3
/
Visual Cafe 3.ISO
/
Vcafe
/
Main.bin
/
DataElem.java
< prev
next >
Wrap
Text File
|
1998-10-21
|
5KB
|
150 lines
package com.symantec.itools.swing;
import java.awt.Color;
import java.util.*;
/**
* DataElem custom data type optionally used by the JChart component that allows you to
* specify label and color information associated with each data point
* @author Michael Hopkins, Symantec
*/
public class DataElem
{
protected double data; // the value at the data point
protected String label; // the name of the data point
protected java.awt.Color color; // the color of the data point;
/**
* Default Constructor
* If a color isn't specified, a color is assigned from the color utility vector
*/
public DataElem()
{
setData( 0.0 );
setLabel( "" );
setColor( (java.awt.Color) graphColors.elementAt( seed % graphColors.size()) );
}
public DataElem( double value )
{
setData( value );
setLabel( "" );
setColor( (java.awt.Color) graphColors.elementAt( seed % graphColors.size()) );
}
public DataElem( double value, String s )
{
setData( value );
setLabel( s );
setColor( (java.awt.Color) graphColors.elementAt( seed % graphColors.size()) );
}
public DataElem( double value, String s, java.awt.Color c )
{
setData( value );
setLabel( s );
setColor( c );
}
/**
* sets the data of current data element
* @param value double to be used for the given data point
* @see #getData
*/
public void setData( double value )
{
data = value;
}
/**
* gets the data of the current data element
* @return data (double) associated with the element
* @see #setData
*/
public double getData( )
{
return data;
}
/**
* sets the label of current data element
* @param s String to be used for the given data point
* @see #getLabel
*/
public void setLabel( String s )
{
label = s;
}
/**
* gets the label of the current data element
* @return label associated with the element
* @see #setLabel
*/
public String getLabel()
{
return label;
}
/**
* sets the color of current data element
* @param c color to be used for the given data point
* @see #getColor
*/
public void setColor( java.awt.Color c )
{
color = c;
}
/**
* gets the color of the current data element
* @return color associated with the element
* @see #setColor
*/
public java.awt.Color getColor()
{
return color;
}
/* Color utility vector useful for assigning colors to charts */
static public Vector graphColors;
static protected int seed = 0;
static {
graphColors = new Vector( 33 );
graphColors.addElement( new Color ( 255, 128, 128 )); // grapefruit
graphColors.addElement( new Color ( 255, 255, 128 )); // lemon
graphColors.addElement( new Color ( 248, 174, 22 )); // orange
graphColors.addElement( new Color ( 128, 255, 128 )); // kiwi
graphColors.addElement( new Color ( 128, 255, 255 )); // baby blue
graphColors.addElement( new Color ( 193, 66, 75 )); // brick red
graphColors.addElement( new Color ( 0, 128, 255 )); // royal blue
graphColors.addElement( new Color ( 255, 200, 228 )); // pink
graphColors.addElement( new Color ( 171, 105, 216 )); // plum
graphColors.addElement( new Color ( 234, 231, 159 )); // sand
graphColors.addElement( new Color ( 251, 201, 106 )); // apricot
graphColors.addElement( new Color ( 234, 234, 0 )); // bananna
graphColors.addElement( new Color ( 33, 133, 131 )); // teal
graphColors.addElement( new Color ( 128, 0, 128 )); // deep purple
graphColors.addElement( new Color ( 184, 3, 252 )); // violet
graphColors.addElement( new Color ( 109, 147, 108 )); // olive
graphColors.addElement( new Color ( 6, 200, 249 )); // light blue
graphColors.addElement( new Color ( 254, 122, 227 )); // hot pink
graphColors.addElement( new Color ( 69, 180, 200 )); // aqua
graphColors.addElement( new Color ( 214, 216, 120 )); // corn
graphColors.addElement( new Color ( 135, 158, 165 )); // blue-gray
graphColors.addElement( new Color ( 177, 228, 204 )); // mint
graphColors.addElement( new Color ( 209, 202, 197 )); // smog
graphColors.addElement( new Color ( 55, 157, 57 )); // pea
graphColors.addElement( new Color ( 70, 47, 166 )); // navy
graphColors.addElement( new Color ( 197, 188, 33 )); // mustard
graphColors.addElement( new Color ( 44, 29, 103 )); // nightfall
graphColors.addElement( new Color ( 35, 100, 100 )); // forrest green
graphColors.addElement( new Color ( 104, 90, 43 )); // chocolate
graphColors.addElement( new Color ( 117, 146, 1 )); // lilypad
graphColors.addElement( new Color ( 134, 104, 34 )); // brown
graphColors.addElement( new Color ( 201, 183, 129 )); // tan
graphColors.addElement( new Color ( 159, 167, 120 )); // heather
}
}